#pragma once

#include "fxcc/core/audio/common/pch.h"

namespace fxcc
{
	namespace audio
	{
		namespace common
		{
            struct FXCC_API Source :public fxcc::Base
			{
                struct FXCC_API Desc
                {
                    std::string m_WavPath;

                    std::string m_OggPath;

                    enum Type {
                        _Wav_ = 0, _Ogg_ = 1,
                    } m_Type;

                    bool SetPath(const std::string& p)
                    {
                        auto suffix = fxcc::Base::GetSuffix(p);

                        if (fxcc::FileUtil::IsOgg(suffix))
                        {
                            m_OggPath = p;
                            m_Type = Type::_Ogg_;
                            return true;
                        }
                        if (fxcc::FileUtil::IsWav(suffix))
                        {
                            m_WavPath = p;
                            m_Type = Type::_Wav_;
                            return true;
                        }
                        return false;
                    }

                    std::string GetFilePath() const
                    {
                        switch (m_Type)
                        {
                        case Type::_Wav_:
                            return m_WavPath;
                        case Type::_Ogg_:
                            return m_OggPath;
                        default:
                            return "";
                        }
                        return "";
                    }

                    bool operator < (const Desc& other) const
                    {
                        return std::tie(m_Type, m_WavPath, m_OggPath) < std::tie(other.m_Type, other.m_WavPath, other.m_OggPath);
                    }
                    bool operator==(const Desc& other) const
                    {
                        return m_Type == other.m_Type &&
                            m_WavPath == other.m_WavPath &&
                            m_OggPath == other.m_OggPath;
                    }
                } m_Desc;

                Source() = default;
                
                Source(const Desc& desc):m_Desc(desc)
                {}


				virtual void Play() const {
                    assert(0 && "common audio Play");
                };
				
				virtual void Pause() const
                {
                    assert(0 && "common audio Pause");
                };

				virtual void Stop() const {
                    assert(0 && "common audio Stop");
                };

			};
		}
	}
}
